#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;



struct item{
	int weight,value;
};



int main(){
	const int inf=0x7fffffff;
	int t,m;
	cin>>t;
	int dp[t+1];
	m = sqrt(sqrt(t));
	item a[m];
	for(int i=0;i<=t;i++)
		dp[i] = inf;
	dp[0] = 0;
	for(int i=1;i<=m;i++){
		a[i-1].weight = i*i*i*i;
		a[i-1].value = 1; 
	}
	for(int i=1;i<=m;i++)
		for(int j=a[i-1].weight;j<=t;j++)
			dp[j] = min(dp[j],dp[j-a[i-1].weight] == inf?inf:dp[j-a[i-1].weight]+a[i-1].value);
	cout<<dp[t];
	return 0;
}
